"use strict";
cc._RF.push(module, '35e61RRAtZLdJgw/w310BxW', 'QQSound');
// Script/Ssg/API/QQ/QQSound.js

"use strict";

var effectPool = null,
    musicPool = {};

var QQSound = cc.Class({

    statics: {

        /**
         * 播放音效
         * @param fileName
         */
        playEffect: function playEffect(fileName) {
            if (!this.effectPool) {
                this.effectPool = BK.createAudioContext({ "type": "effect" });
            }
            this.effectPool.src = 'GameRes://res/raw-assets/resources/Sound/' + fileName;
            this.effectPool.play();
        },

        /**
         * 播放音乐
         * @param fileName
         * @param isLoop
         */
        playMusic: function playMusic(fileName, isLoop) {
            if (!this.musicPool[fileName]) {
                this.musicPool[fileName] = BK.createAudioContext();
                this.musicPool[fileName].loop = isLoop;
                this.musicPool[fileName].src = 'GameRes://res/raw-assets/resources/Sound/' + fileName;
            }
            this.musicPool[fileName].play();
        },

        stopMusic: function stopMusic(fileName) {
            if (fileName) {
                this.musicPool[fileName].stop();
                this.musicPool[fileName].destroy();
                this.musicPool[fileName] = null;
                return;
            }
            for (var p in this.musicPool) {
                this.musicPool[p].stop();
                this.musicPool[p].destroy();
                this.musicPool[p] = null;
            }
        },

        /**
         * 暂停音乐
         * @param fileName
         */
        pauseMusic: function pauseMusic(fileName) {
            if (fileName) {
                this.musicPool[fileName].pause();
                return;
            }
            for (var p in this.musicPool) {
                this.musicPool[p].pause();
            }
        },

        /**
         * 恢复音乐播放
         * @param fileName
         */
        resumeMusic: function resumeMusic(fileName) {
            if (fileName) {
                this.musicPool[fileName].play();
                return;
            }
            for (var p in this.musicPool) {
                this.musicPool[p].play();
            }
        }

    }
});

module.exports = QQSound;

cc._RF.pop();